package it.wzm.lightweightlog;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Properties;

public abstract class RegisterDecorator<T extends Dumper> extends Register<T> {

	/**
	 * Register holder
	 */
	private Register<T> r;
	
	protected RegisterDecorator(Register<T> r) {
		// basic check then assign to variable...
		if (r==null)
			throw new RegisterInitializationException("Cannot construct with Register null");
		
		this.r=r;		
	}
	
	/**
	 * 
	 * @return valid register
	 */
	protected Register<T> getRegister() {
		return this.r;
	}
	
	/* (non-Javadoc)
	 * @see it.wzm.lightweightlog.Register#dispatchToDumper(it.wzm.lightweightlog.Entry)
	 */
	@Override
	<E extends Entry> void dispatchToDumper(E e) {
		this.getRegister().dispatchToDumper(e);		
	}

	/* (non-Javadoc)
	 * @see it.wzm.lightweightlog.Register#dispatchToDumper(java.util.LinkedList)
	 */
	@Override
	<E extends Entry> void dispatchToDumper(LinkedList<E> ll) {
		this.getRegister().dispatchToDumper(ll);		
	}

	/* (non-Javadoc)
	 * @see it.wzm.lightweightlog.Register#get(java.lang.String)
	 */
	@Override
	protected String get(String name) {
		return this.getRegister().get(name);
	}

	/* (non-Javadoc)
	 * @see it.wzm.lightweightlog.Register#postinit()
	 */
	@Override
	void postinit() {
		this.getRegister().postinit();
	}

	/* (non-Javadoc)
	 * @see it.wzm.lightweightlog.Register#preinit()
	 */
	@Override
	void preinit() {
		this.getRegister().preinit();
	}

	/* (non-Javadoc)
	 * @see it.wzm.lightweightlog.Register#remove(it.wzm.lightweightlog.Dumper)
	 */
	@Override
	boolean remove(T t) {
		return this.getRegister().remove(t);
	}

	/* (non-Javadoc)
	 * @see it.wzm.lightweightlog.Register#save(it.wzm.lightweightlog.Dumper)
	 */
	@Override
	boolean save(T t) {
		return this.getRegister().save(t);
	}

	/* (non-Javadoc)
	 * @see it.wzm.lightweightlog.Register#shutdown()
	 */
	@Override
	void shutdown() {
		// TODO Auto-generated method stub
		
	}

	/* (non-Javadoc)
	 * @see it.wzm.lightweightlog.Register#size()
	 */
	@Override
	int size() {
		// TODO Auto-generated method stub
		return 0;
	}

	/* (non-Javadoc)
	 * @see it.wzm.lightweightlog.Register#toString()
	 */
	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return super.toString();
	}

	public RegisterDecorator(Properties p, ArrayList<T> t) {
		super(p, t);
	}

}
